/*
 * @Descripttion: redux-thunk的源码解读
 * @Author: lukasavage
 * @Date: 2021-11-27 11:49:52
 * @LastEditors: lukasavage
 * @LastEditTime: 2021-11-28 11:09:46
 */


function thunk({ getState, dispatch }) {
    return function (next) {
        return function(action) {
            if(typeof action === 'function') {
                // 执行函数，并且传入dispatch和getState
                return action(dispatch, getState);
            }
            // 执行原始的store.dispatch方法
            return next(action);
        }
    }
}

export default thunk;